with(combinat): helpYPP:=proc() print(`redu(), classifier(pi, l)`); end: #inputs a list of numbers, and outputs the reduction as a permutation of nops(L) #redu([e,pi,gamma,phi, h])=[ 4, 5 , 2 , 3 ,1] redu:=proc(L) local L1,T,k,i: L1:=sort(sort(L,'output'='permutation'),'output'='permutation'): end: #classifier(pi,l) takes a permutation pi and a prefix length l and outputs a list with two elements. The first element is a copy of the portion of the original permutation following the prefix, but each element is replaced with the number of prefix elements that it exceeds, plus one. The second element is a list with two more elements than the number of elements in the prefix. The ith element is the reduction of the subpermutation formed by only considering the elements of the original permutation greater than exactly (i-1) permutation elements, and the last element is the reduction of the prefix. classifier:=proc(pi, l) local n,i,el1, el2,j,k: n:=nops(pi): el1:=[]: el2:=[[]$(l+2)]: for i from l+1 to n do j:=0: for k from 1 to l do if pi[k]